<template>
	<view>
		<view class="zy-display-flex">
			<view class="zy-type-title zy-text-bold">提现记录</view>
		</view>
		<view class="zy-commission-record">
			<view v-if="withdrawList.length > 0" class="zy-page-list" style="padding: 0upx 30upx;">
				<view v-for="(withdrawItem, index) in withdrawList" :key="index" v-if="withdrawItem.amount > 0" class="zy-page-list-item">
					<view class="zy-display-flex">
						<view class="zy-text-big zy-text-bold zy-overflow-hidden">{{withdrawItem.transactionNo}}</view>
						<view class="zy-text-info zy-text-bold zy-display-flex-right" style="color: #fa436a; font-size: 36upx;">
							{{withdrawItem.amount > 0 ? '+' : ''}}{{withdrawItem.amount}}
						</view>
					</view>
					<view class="zy-display-flex" style="justify-content: space-between;">
						<view>
							<view>申请时间：{{withdrawItem.createTime}}</view>
							<view>完成时间：{{withdrawItem.completeTime || ''}}</view>
							<view>提现描述：{{withdrawItem.withdrawDescription || '暂无'}}</view>
						</view>
						<view>
							<text style="color:#FA436A;">{{statusArray[withdrawItem.withdrawStatus]}}</text>
						</view>
					</view>
				</view>
				<uni-pagination :current="pager.pageNo" :total="pager.pageTotal" title="标题文字" prev-text="前一页" next-text="后一页" @change="changePageTotal" />
			</view>
			<zywork-no-data v-else text="暂无提现记录"></zywork-no-data>
		</view>
		
	</view>
</template>

<script>
	import zyworkNoData from '@/components/zywork-no-data/zywork-no-data.vue'
	import zyworkIcon from '@/components/zywork-icon/zywork-icon.vue'
	import uniPagination from '@/components/uni-pagination/uni-pagination.vue'
	import {
		withdrawStatusArray
	} from '@/common/picker-data.js'
	import { 
		doPostJson,
		showInfoToast
	} from '@/common/util.js'
	import * as ResponseStatus from '@/common/response-status.js'
	
	export default {
		components: {
			zyworkNoData,
			zyworkIcon,
			uniPagination
		},
		data() {
			return {
				withdrawList: [],
				urls: {
					searchUrl: '/funds-withdraw/user/pager-cond'
				},
				pager: {
					pageNo: 1,
					pageSize: 20,
					isActive: 0,
					pageTotal: 0,
				},
				statusArray: withdrawStatusArray,
			}
		},
		onLoad() {
			uni.hideShareMenu()
			this.loadData()
		},
		methods: {
			/**
			 * 切换分页
			 * @param {Object} e
			 */
			changePageTotal(e) {
				console.log(e.current)
				this.pager.pageNo = e.current
				this.loadData()
			},
			/**
			 * 加载数据
			 */
			loadData() {
				doPostJson(this.urls.searchUrl, this.pager, {}, true).then(response => {
					let [error, res] = response
					if (res.data.code === ResponseStatus.OK) {
						this.withdrawList = res.data.data.rows
						this.pager.pageTotal = res.data.data.total
					}
				}).catch(error => {
					console.log(error)
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/zywork-main.scss';
	
	.zy-commission-card {
		height: 200upx;
		background-color:#f1f1f1;
		text-align: center;
		margin: 30upx 20upx;
		border-radius: 20upx;
		padding-top: 60upx;
	}
	
	.zy-commission {
		color: #fa436a;
		font-size: 64upx;
	}
	
	.zy-type-picker {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-right: 10upx;
		width: 100upx;
	}
	
	.zy-commission-record {
		margin: 10upx 20upx;
	}
	
</style>
